package demo7;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/*
 * 了解容器管理对象时生命周期对应的各个方法
 */
@Component
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private int age;

    public Person() {
        System.out.println("1：person（）的构造器执行了");
    }

    @Value("张三")
    public void setName(String name) {
        System.out.println("2：setName()方法执行了");
        this.name = name;
    }
    @Value("18")
    public void setAge(int age) {
        System.out.println("2：setAge()方法执行了");
        this.age = age;
    }
    public void play() {
        System.out.println("3：Person中的正常功能方法play（）执行了，输出：" );
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("4：afterPropertiesSet()方法执行了");
    }
    @Override
    public void destroy() throws Exception {
        System.out.println("5：容器即将销毁，通知person，调用destroy()方法了");
    }

}
